package co.com.jtune.view.main;

import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jdesktop.application.ResourceMap;

import co.com.jtune.view.util.ComponentBorder;
import co.com.jtune.view.util.ComponentBorder.Edge;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

public class SearchPanel extends JPanel{
	
	private static final long serialVersionUID = 1L;
	
	private JTextField search;
	
	private ResourceMap resource;
	
	public SearchPanel(ResourceMap resource)
	{
		this.resource = resource;
		
		buildComponets();
		createSimpleGui();
	}

	private void buildComponets() {
		
		search = new JTextField();
		search.setPreferredSize(new Dimension(130, 20));
		
		JLabel searchImg = new JLabel(resource.getImageIcon("SearchPanel.searchIcon"));
		searchImg.setBackground(null);
		ComponentBorder cb = new ComponentBorder( searchImg, Edge.LEFT);
		cb.install(search);
	}
	
	private void createSimpleGui() {
		FormLayout panelLayout = new FormLayout( "5px:grow, 130px, 5px", "5px:grow, pref, 5px:grow");		
		setLayout(panelLayout);
		setBorder(BorderFactory.createTitledBorder(""));
		
		CellConstraints cc = new CellConstraints();
		
		add(search, cc.xywh(2, 2, 1, 1, CellConstraints.FILL, CellConstraints.FILL));
	}


}
